# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


from os.path import basename, dirname, join
from urllib.parse import urlparse

# useful for handling different item types with a single interface
from scrapy.pipelines.files import FilesPipeline


class MatplolibExamplesPipeline:

    def process_item(self, item, spider):
        return item


class MyFilesPipeline(FilesPipeline):
    def file_path(self, request, response=None, info=None):
        path = urlparse(request.url).path
        return join(basename(dirname(path)), basename(path))
